﻿using Daemon.Service.Contract;
using Daemon.Model;
using Microsoft.AspNetCore.Http;
using System.Linq;
using System;
using Microsoft.AspNetCore.Mvc;
using Daemon.Repository.Contract;
using System.Collections;
using System.Collections.Generic;

namespace Daemon.Service
{
	public class TakeAwayGoodTypeService : ITakeAwayGoodTypeService
	{
		private readonly ITakeAwayGoodTypeRepository _takeAwayGoodTypeRepository;
		public TakeAwayGoodTypeService(ITakeAwayGoodTypeRepository takeAwayGoodTypeRepository)
		{
			_takeAwayGoodTypeRepository = takeAwayGoodTypeRepository;
		}

		public IEnumerable<TakeAwayGoodType> GetAllByShopId(int shopId)
		{
			var result = _takeAwayGoodTypeRepository.FindAll().Where(r => r.ShopId == shopId);
		   _takeAwayGoodTypeRepository.SetRelationships(new List<Model.Entities.Relationship>() { new Model.Entities.Relationship() { Name = "GoodList" } });
			return _takeAwayGoodTypeRepository.IncludeRelationships(result);
		}
	}
}
